//! # 构建器模块测试
//! 
//! 本模块包含对构建器功能的测试用例。

#[cfg(test)]
mod tests {
    use super::*;
    use crate::builder::simple::RustCloudBuilder;
    use crate::builder::config_builder::{ServiceConfigBuilder, NetworkConfigBuilder};

    #[tokio::test]
    async fn test_builder_basic() {
        let builder = RustCloudBuilder::new("test-service")
            .with_version("1.0.0")
            .with_environment("test")
            .with_port(8080);

        assert_eq!(builder.get_config().service.name, "test-service");
        assert_eq!(builder.get_config().service.version, "1.0.0");
        assert_eq!(builder.get_config().service.environment, "test");
        assert_eq!(builder.get_config().network.port, 8080);
    }

    #[tokio::test]
    async fn test_builder_with_registry() {
        let builder = RustCloudBuilder::new("test-service")
            .with_registry("nacos://localhost:8848");

        assert_eq!(builder.get_config().components.registry.registry_type, "nacos");
        assert_eq!(builder.get_config().components.registry.endpoints, vec!["localhost:8848"]);
    }

    #[tokio::test]
    async fn test_service_config_builder() {
        let config = ServiceConfigBuilder::new("my-service")
            .version("2.0.0")
            .environment("production")
            .tag("team", "backend")
            .build()
            .unwrap();

        assert_eq!(config.name, "my-service");
        assert_eq!(config.version, "2.0.0");
        assert_eq!(config.environment, "production");
        assert_eq!(config.tags.get("team"), Some(&"backend".to_string()));
    }

    #[tokio::test]
    async fn test_network_config_builder() {
        let config = NetworkConfigBuilder::new()
            .port(9090)
            .health_port(9091)
            .bind_address("127.0.0.1")
            .build()
            .unwrap();

        assert_eq!(config.port, 9090);
        assert_eq!(config.health_port, 9091);
        assert_eq!(config.bind_address, "127.0.0.1");
    }
}